# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Jordan Day < jordanday444 at gmail dot com >
# Contributor: Florian Dejonckheere <florian at floriandejonckheere dot be>
# Contributor: Eric Forgeot < http://anamnese.online.fr >

pkgname=goattracker
pkgver=2.76
pkgrel=3
pkgdesc='Cross-platform C64 music tracker'
arch=('loong64' 'x86_64')
url='https://sourceforge.net/projects/goattracker2'
license=('GPL')
depends=(
  'gcc-libs'
  'sdl12-compat'
  'hicolor-icon-theme'
)
makedepends=('gendesk')
source=("$pkgname-$pkgver.zip::https://sourceforge.net/projects/goattracker2/files/GoatTracker%202/$pkgver/GoatTracker_$pkgver.zip/download")
sha512sums=('977a5df7e105ec4bb5adbdc051025e2a20dd0dfb88d8a0770a94d1e59d8f0172155f54aaf7676651a5b86fdc08c25728eaf55a6a2f6be9b3a8d323839179b14c')
b2sums=('cd6bd318bd8d4ef847a7d3dd278df981a787c1576e2de69f1ef21130dc446290c46c705e1729dda61ef65dbc7173e84dd838b60f290cd10d98d0f42f83d0ee5b')

prepare() {
  cd src

  gendesk -n \
    --pkgname "$pkgname" \
    --pkgdesc "$pkgdesc" \
    --name 'GoatTracker' \
    --exec 'goattracker %F' \
    --genericname 'C64 Music tracker' \
    --categories 'AudioVideo;AudioVideoEditing' \
    --icon "$pkgname" \
    --mimetypes 'audio/sng'
}

build() {
  cd src

  make clean

  make
}

package() {
  # binaries
  find linux -type f -executable -exec install -vDm755 -t "$pkgdir/usr/bin" {} +
  mv "$pkgdir/usr/bin/"{goattrk2,goattracker}

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" goat_tracker_commands.pdf readme.txt
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname/examples" examples/*.{sng,txt,ins,prg}

  # man page
  install -vDm644 -t "$pkgdir/usr/share/man/man1" linux/goattracker.1

  # desktop file
  install -vDm644 -t "$pkgdir/usr/share/applications" src/goattracker.desktop

  # application icon
  install -vDm644 morphos/goattrk2.info "$pkgdir/usr/share/icons/hicolor/32x32/apps/$pkgname.png"
}
